package com.nopcomm.admin;


import junit.framework.Assert;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import com.nopcomm.abstractTest;
import com.nopcomm.pages.Categorypage;
import com.nopcomm.pages.CreateAndEditConsumerPage;
import com.nopcomm.pages.DashboardPage;
import com.nopcomm.pages.Homepage;

public class RegressionTestSuite extends abstractTest {
	//Test Data
		String Email =   "admin@yourstore.com";
		String Password = "adminadmin";
		String NewcustomerEmail ="Naidu@gmail.com";
		String gender ="male";
		String NewCustomerpassword ="smsms";
		String NewcustomerFirstname="Naidu";
		String NewcustomerLastname="Rahul";
		String NewcustomerDateofBirth="12/30/2012";
		String RoleName ="Registered";
		String categoryname ="Computers";
		String path = "C:\\Users\\Rahul Naidu\\Pictures\\desktop.jpg";
		String parentcategory ="Electronics";
		String pricerange   = "10000";
		//End of Test Data
		@Before
		public void AdminLogin(){
		//Login as Admin
		Homepage homepage = new Homepage();
		homepage.gotologin(Email,Password);}
		 @After
		public void AdminLogout(){
		Homepage homepage = new Homepage();
		homepage.gotologout();}
	   
		    @Test
			public void Verifyusercancreatecustomer(){
				//go to consumers
				DashboardPage Admindashboard = new DashboardPage();
		 		Admindashboard.gotoconsumer();
		 		//search for consumer
		 		CreateAndEditConsumerPage consumer  = new CreateAndEditConsumerPage ();
		 		consumer.createconsumer(NewcustomerEmail,NewCustomerpassword,gender,
		 		NewcustomerFirstname,NewcustomerLastname,NewcustomerDateofBirth);
		 		//select role
		 		consumer.selectroles(RoleName);
		 		//save
		 		consumer.saveConsumer();
				//Checkpoint
				Assert.assertTrue( DashboardPage.isSuccessmessage());}

			@Test
			public void verifyUserCanSearchCustomers(){
				//go to consumers
				DashboardPage Admindashboard = new DashboardPage();
				Admindashboard.gotoconsumer();
				//search for consumer
				CreateAndEditConsumerPage consumer  = new CreateAndEditConsumerPage ();
				consumer.searchCustomer(NewcustomerEmail,RoleName);
				//checkpoint
		       Assert.assertTrue(CreateAndEditConsumerPage .isEmailShown(NewcustomerEmail));}

			@Test
			public void verifyUsercanEditCustomer(){
		        //go to customers
				DashboardPage dashboard= new DashboardPage();
				dashboard.gotoconsumer();
				//search customers
				CreateAndEditConsumerPage consumer  = new CreateAndEditConsumerPage ();
				consumer.searchCustomer(NewcustomerEmail, RoleName);
				//edit consumer
				consumer.editCustomer(NewcustomerEmail);
				//checkpoint
				Assert.assertTrue(consumer.isMesgShown());}
		    @Test
		    public void verifyusercansearchanddeletecustomer(){
		    	//go to customers
		    	DashboardPage dashboard= new DashboardPage();
				dashboard.gotoconsumer();
				//Search customers
				CreateAndEditConsumerPage consumer  = new CreateAndEditConsumerPage ();
				consumer.searchCustomer(NewcustomerEmail, RoleName);
				//Delete customers
				consumer.DeleteCustomer(NewcustomerEmail);
				//Check Point
				Assert.assertTrue(consumer.isdeletedmesgShown());}
		    
		   @Test
		    public void verifyUserCanCreateCategory(){
		    	//go category
		    	DashboardPage dashboard= new DashboardPage();
				dashboard.gotoCategory();
				//Create new Category
				Categorypage category = new Categorypage();
				category.createNewCategory(categoryname,path,parentcategory,pricerange);
				//Checkpoint
				Assert.assertTrue(category.isCategorymesgshown()); }
		    
		    @Test
		    public void verifyUserCanSearchCategory(){
		    	//go category
		    	DashboardPage dashboard= new DashboardPage();
				dashboard.gotoCategory();
				//search category
				Categorypage category = new Categorypage();
				category.searchcategory(categoryname);
				//checkpoint
				Assert.assertTrue(category.getcategory(categoryname));
		    }
		    
		    @Test
		    public void VeriyUsercanDeleteCategory(){
		    	DashboardPage dashboard= new DashboardPage();
				dashboard.gotoCategory();
				//search category
				Categorypage category = new Categorypage();
				category.searchcategory(categoryname);
				//delte category
				category.deletecategory(categoryname);
				//check point
				Assert.assertTrue(category.isDeletemeshshown());
		    }
		    }
